home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / bbsckit.zip / BBSC.C < prev    next >
C/C++ Source or Header  |  1980-01-01  |  38KB  |  1,135 lines

  1. /*
  2.         bbsc.c
  3.  
  4.         BBS (Bulletin Board System) written in UNIX SYSTEM-III "C".
  5.  
  6.                 Support files needed:
  7.                         bbscdef.h
  8.                         bbscport.o or bbscport.c
  9.                         bbsclock.o or bbsclock.c
  10.                         bbscfile.o or bbscfile.c
  11.                         bbscmisc.o or bbscmisc.c
  12.  
  13.                                 Mike Kelly
  14.  
  15.         03/09/83 v1.0   written
  16.         07/07/83 v1.0   updated
  17. */
  18. #include "bbscdef.h"
  19.  
  20. #define LASTDATE  " 02/07/84 "
  21.  
  22. #define PGMNAME "BBSc    "
  23. #define VERSION " 1.1 "
  24.  
  25.  
  26. main()
  27.         {
  28.         int     i;
  29. /*
  30. *               init global variables
  31. */
  32.         debug   = FALSE;
  33.         statcnt = 0;
  34.         xpert   = FALSE;
  35.         active  = TRUE;
  36.  
  37.         w_fname[0] = '\0';
  38.         w_lname[0] = '\0';
  39.         strcpy(w_password,"MPK0");
  40.  
  41.         u_fname[0] = '\0';
  42.         u_lname[0] = '\0';
  43.         strcpy(u_password,"MPK0");
  44.         u_time1[0] = '\0';
  45.         u_date1[0] = '\0';
  46.         u_time2[0] = '\0';
  47.         u_date2[0] = '\0';
  48.         u_city[0]  = '\0';
  49.  
  50.         mm[0]    = '\0';
  51.         dd[0]    = '\0';
  52.         yy[0]    = '\0';
  53.         month[0] = '\0';
  54.         day[0]   = '\0';
  55.         year[0]  = '\0';
  56.         date[0]  = '\0';
  57.         week[0]  = '\0';
  58.         ttime[0] = '\0';
  59.  
  60.         strcpy(msg_delete,"0");
  61.         msg_no[0]   = '\0';
  62.         msg_date[0] = '\0';
  63.         msg_date[0] = '\0';
  64.         msg_time[0] = '\0';
  65.         msg_to[0]   = '\0';
  66.         msg_from[0] = '\0';
  67.         msg_pass[0] = '\0';
  68.         msg_subject[0] = '\0';
  69.         msg_text[0] = '\0';
  70.  
  71.         stop_that = FALSE;
  72.  
  73. /*       get date and time from the clock       */
  74.  
  75.         gettime(ttime);
  76.         getdate(mm,dd,yy,month,day,year,date,week);
  77.  
  78.         portinit() ;    /* init terminal modes */
  79.         signon()   ;
  80.         driver()   ;
  81.         portrst()  ;    /* undo any special modes */            
  82.         }
  83. /*      end of mainline routine         */
  84.  
  85. driver()
  86.         {
  87. char    linebuf[MAXLINE],
  88.         buf[128],
  89.         *bufptr,                /* ptr to buf */
  90.         usercd[100],            /* user record */
  91.         *userptr,               /* ptr to usercd */
  92.         cmd[2];
  93.  
  94. int     cnt,
  95.         ok_sw,
  96.         case_sw,
  97.         i,
  98.         num0,
  99.         num1,
  100.         num2;
  101.  
  102.         cnt     = 0;
  103.         ok_sw   = TRUE;
  104.         bufptr  = buf;
  105.         xpert   = FALSE;
  106.         cmd[0]  = '\0';
  107.  
  108.         while (active)
  109.                 {
  110.                 stop_that = FALSE ;             /* reset switch */
  111.                 portsout(CRLF);
  112.                 if (!xpert)
  113.                         {
  114.                         portsout("Commands: B,C,E,G,K,N,Q,R,S,W,X or ? ");
  115.                         }
  116.                 portsout("===> ");
  117.                 portsin(cmd,1);
  118.                 portsout(CRLF);
  119.  
  120.                 *cmd = toupper(*cmd) ;
  121.  
  122.                 switch (cmd[0])
  123.                         {
  124.                         case ('C'):             /* Unix */
  125.                                 cmd_c();
  126.                                 break;
  127.                         case ('E'):             /* enter msg */
  128.                                 cmd_e();
  129.                                 break;
  130.                         case ('G'):             /* goodby */
  131.                                 cmd_g();
  132.                                 break;
  133.                         case ('K'):             /* kill msg */
  134.                                 cmd_k();
  135.                                 break;
  136.                         case ('Q'):             /* quick scan */
  137.                                 cmd_q();
  138.                                 break;
  139.                         case ('R'):             /* read msg */
  140.                                 cmd_r();
  141.                                 break;
  142.                         case ('S'):             /* scan msg */
  143.                                 cmd_s();
  144.                                 break;
  145.                         case ('X'):             /* expert toggle */
  146.                                 cmd_x();
  147.                                 break;
  148.                         case ('N'):             /* print new-user stuff */
  149.                                 cmd_p(NEWUSER);
  150.                                 break;
  151.                         case ('W'):             /* print welcome file */
  152.                                 cmd_p(WELCOME);
  153.                                 break;
  154.                         case ('B'):             /* print bulletins */
  155.                                 cmd_p(BULLETINS);
  156.                                 break;
  157.                         case ('?'):             /* help */
  158.                                 cmd_p(HELP);
  159.                                 break;
  160.                         default:
  161.                                 break;
  162.                         }
  163.  
  164.                 }
  165.         }
  166. /*      end of function         */
  167.  
  168. cmd_g()                 /* good-by */
  169.         {
  170.         active = FALSE;
  171.         portsout("\r\nThanks for calling ");
  172.         portsout(w_fname) ;
  173.         portsout(CRLF)    ;
  174.         sleep(5)          ;             /* for the Smartmodem */
  175.         portsout("+")     ;             /* get the modems attention */
  176.         portsout("+")     ;             /* get the modems attention */
  177.         portsout("+")     ;             /* get the modems attention */
  178.         sleep(15)         ;                     /* for the Smartmodem */
  179.         gobble()          ;
  180.         portsout("ATH")   ;             /* hang up the phone */
  181.         portsout(CRLF)    ;
  182.         sleep(15)         ;                     /* for the Smartmodem */
  183.         }
  184. /*      end of function         */
  185.  
  186. cmd_c()                 /* go to the operating system level */
  187.         {
  188.         if ((inbuf=fopen(SYSTEM,"r")) == NULL)
  189.                 {
  190.                 portsout(CRLF) ;
  191.                 portsout("Exiting to the operating system level!") ;
  192.                 portsout(CRLF) ;
  193.                 }
  194.         else
  195.                 {
  196.                 porttype(inbuf);        /* type a file to port */
  197.                 close(inbuf);
  198.                 }
  199.         active = FALSE;
  200.         }
  201. /*      end of function         */
  202.  
  203. cmd_e()                 /* enter a message */
  204.         {
  205.         int     entering,
  206.                 editing,
  207.                 cnt1;
  208.         char    msg[50],
  209.                 l_cnt[3],
  210.                 ans[2];
  211.  
  212.         entering = editing = TRUE;
  213.         cnt1 = 0;
  214.         l_cnt[0] = '0';                 /* init line count */
  215.         msg_text[0] = '\0';             /* init message text area */
  216.  
  217.         portsout(CRLF);
  218.         portsout("This will be message # ");
  219.         portsout(h_next_msg);
  220.         portsout(CRLF);
  221.         portsout("                             ____.____1____.____2\r\n");
  222.         portsout("Who is the message for  ===> ");
  223.         portsin(msg_to,20);
  224.         portsout(CRLF);
  225.         portsout("What is the subject     ===> ");
  226.         portsin(msg_subject,20);
  227.         portsout(CRLF);
  228.  
  229.         portsout(CRLF) ;
  230.         portsout("A line can contain 40 characters, up to 20 lines.") ;
  231.         portsout(CRLF) ;
  232.         portsout("To end, enter a carriage return on an empty line.") ;
  233.         portsout(CRLF) ;
  234.         portsout(CRLF) ;
  235.         portsout("    .___.____1____.____2____.____3____.____4") ;
  236.         portsout(CRLF) ;
  237.  
  238.         while (entering)                /* get the text of the message */
  239.                 {
  240.                 linecnt(l_cnt);         /* calc line count */
  241.  
  242.                 portsout(l_cnt);        /* show line count */
  243.                 portsout("> ");         /*  and prompt */
  244.  
  245.                 portsin(msg,40);
  246.                 portsout(CRLF);
  247.  
  248.                 strcat(msg,"\n");       /* put a <lf> on each line */
  249.  
  250.                 if (strlen(msg) < 2)            /* count cr too */
  251.                         {
  252.                         entering = FALSE;       /* all done */
  253.                         }
  254.                 else
  255.                         {
  256.                         strcat(msg_text,msg);   /* append each line